package model

import (
	"gorm.io/gorm"
	"zk2/you-ku-dev/video-server/basic/config"
)

type Video struct {
	gorm.Model
	Title    string `gorm:"type:varchar(30);comment:标题"`
	Type     string `gorm:"type:varchar(30);comment:类型"`
	VideoUrl string `gorm:"type:varchar(300);comment:文件地址"`
}

func CreateVideo(v *Video) error {

	return config.DB.Create(&v).Error
}

type TVSeries struct { //电视剧
	gorm.Model
	Name    string `gorm:"type:varchar(30);comment:电视剧名称"`
	Content string `gorm:"type:varchar(100);comment:电视剧内容"`
	TvTime  string `gorm:"type:varchar(100);comment:电视剧时长"`
}

func CreateTv(t *TVSeries) error {

	return config.DB.Create(&t).Error
}

type Series struct { //剧集
	gorm.Model
	Tid   int    `gorm:"type:int(11);comment:电视剧ID"`
	Title string `gorm:"type:varchar(30);comment:剧集标题"`
	Free  int    `gorm:"type:int(11);comment 0 免费 1 付费"`
	STime string `gorm:"type:varchar(100);comment:剧集时长"`
}

func CreateSeries(s *Series) error {

	return config.DB.Create(&s).Error
}

type Pram struct {
	gorm.Model
	Name    string `gorm:"type:varchar(30);comment:剧名"`
	Type    string `gorm:"type:varchar(30);comment:类型"`
	Address string `gorm:"type:varchar(50);comment:制片方"`
	SID     int    `gorm:"type:int(11);分集ID"`
}

func CreatePram(p *Pram) error {

	return config.DB.Create(&p).Error
}

type VideoStatus struct {
	gorm.Model
	VideoId int    `gorm:"type:int(11);comment:视频ID"`
	Status  string `gorm:"type:varchar(30);comment:状态"`
	Text    string `gorm:"type:varchar(100);comment:意见"`
}

func CreateStatus(s *VideoStatus) error {

	return config.DB.Create(&s).Error
}

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30);comment:用户名"`
	Free     int    `gorm:"type:varchar(30);comment:是否为会员 1 是  2 不是"`
}

func CreateUser(u *User) error {

	return config.DB.Create(&u).Error
}

func FindUser(u *User, free int) error {

	return config.DB.Where("free=?", free).Find(&u).Error
}
